home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / art&graf.ix / art-0015 / flicker / circle.asm < prev    next >
Assembly Source File  |  1997-04-16  |  2KB  |  86 lines

  1.  
  2.     public _plot
  3.  
  4.     ;circle(x, y, rad, color)
  5.     ;    draw a circle of radius rad about center x,y in color
  6.     public _circle
  7.  
  8. param1    equ    5*2+4+6    ; offset on stack to first parameter after register saved
  9. x    equ    param1
  10. y    equ  param1+2
  11. rad equ    param1+4
  12. color equ param1+6
  13. _circle
  14.     movem.w    d3/d4/d5/d6/d7,-(sp)
  15.     subq.l    #6,sp    ; make room for parameters to plot
  16.  
  17.     move.w    color(sp),4(sp)    ; set up color parameter for plot
  18.     move.w    x(sp),d6    ; save center xy
  19.     move.w    y(sp),d7
  20.     move.w    rad(sp),d4    ; xoffset starts out radius
  21.     bne        nontrivc    ; it's not zero radius...do a circle
  22.     move.w    d6,(sp)
  23.     move.w    d7,2(sp)
  24.     jsr        _plot        ; else just plot one point... 
  25.     bra        endcloop
  26. nontrivc
  27.     move.w    #0,d5        ; yoffset starts out zero
  28.     move.w    d4,d3
  29.     neg.w    d3
  30.     asr.w    #1,d3        ; d3 = error = -rad/2
  31. cloop
  32.     tst.w    d4
  33.     bmi        endcloop
  34.  
  35.     ;    plot 1st quadrant
  36.     move.w    d6,d0
  37.     add.w    d4,d0
  38.     move.w    d0,(sp)    ; x coordinate for plot
  39.     move.w    d7,d0
  40.     add.w    d5,d0
  41.     move.w    d0,2(sp) ; y coordinate for plot
  42.     jsr        _plot
  43.  
  44.     ;    plot 2nd quadrant
  45.     move.w    d6,d0
  46.     sub.w    d4,d0
  47.     move.w    d0,(sp)    ; x coordinate for plot
  48.     move.w    d7,d0
  49.     add.w    d5,d0
  50.     move.w    d0,2(sp) ; y coordinate for plot
  51.     jsr        _plot
  52.  
  53.     ;    plot 3rd quadrant
  54.     move.w    d6,d0
  55.     sub.w    d4,d0
  56.     move.w    d0,(sp)    ; x coordinate for plot
  57.     move.w    d7,d0
  58.     sub.w    d5,d0
  59.     move.w    d0,2(sp) ; y coordinate for plot
  60.     jsr        _plot
  61.  
  62.     ;    plot 4th quadrant
  63.     move.w    d6,d0
  64.     add.w    d4,d0
  65.     move.w    d0,(sp)    ; x coordinate for plot
  66.     move.w    d7,d0
  67.     sub.w    d5,d0
  68.     move.w    d0,2(sp) ; y coordinate for plot
  69.     jsr        _plot
  70.  
  71.     ; now do stuff to figure out where next 4 plots will be
  72.     tst.w    d3        ; check sign of error term
  73.     bpl        stepx
  74.     addq.w    #1,d5    ; increment y offset
  75.     add.w    d5,d3    ; update error term
  76.     bra     cloop
  77. stepx    subq.w    #1,d4
  78.     sub.w    d4,d3
  79.     bra        cloop
  80.  
  81. endcloop
  82.     addq.l    #6,sp    ; clean off plot parameters
  83.     movem.w    (sp)+,d3/d4/d5/d6/d7
  84.     rts
  85.  
  86.